#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@crane-pc>
#
# Distributed under terms of the MIT license.

"""

"""

ugly_list = [1, 1]


class Solution:
    @staticmethod
    def get_block_ugly(n):
        i = j = k = 1
        for iter in range(n-1):

            num = min([
                2 * ugly_list[i],
                3 * ugly_list[j],
                5 * ugly_list[k] ])

            ugly_list.append(num)

            if num == (2 * ugly_list[i]):
                i += 1

            if num == (3 * ugly_list[j]):
                j += 1

            if num == (5 * ugly_list[k]):
                k += 1


    def nthUglyNumber(self, nth):
        return ugly_list[nth]

s = Solution()
s.get_block_ugly(2000)
# print(len(ugly_list))
# print(s.nthUglyNumber(41))


# def main():
#     print("start main")
#     print(ugly_list[2])
#     print(ugly_list[41])
#     print(ugly_list[560])
#     print(ugly_list[570])
#     # print(ugly_list[600])

# if __name__ == "__main__":
#     main()
